#include <iostream>
#include <bits/stdc++.h>

using namespace std;


int func(int index, vector<int> &array, int strength, int intelligence) {
    int n = array.size();
    if (index >= n) {
        return 0;
    }
    int ans = 0;
    if (array[index] == 0) {
        //要么加智力, 要么力量
        ans = max(func(index + 1, array, strength + 1, intelligence),
                  func(index + 1, array, strength, intelligence + 1));
    } else if (array[index] > 0) {
        if (intelligence >= array[index]) {
            ans = func(index + 1, array, strength, intelligence) + 1;
        } else {
            ans = func(index + 1, array, strength, intelligence);
        }
    } else {
        if (strength >= abs(array[index])) {
            ans = func(index + 1, array, strength, intelligence) + 1;
        } else {
            ans = func(index + 1, array, strength, intelligence);
        }
    }
    return ans;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> array(n);
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    cout << func(0, array, 0, 0) << "\n";
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);


    solve();

    return 0;
}


